#include <stdio.h>
#include <stdlib.h>

#define TAG_NONE 0
#define TAG_OPEN_CODE 1
#define TAG_CLOSE_CODE 2

#define BUF_TYPE_HTML 0
#define BUF_TYPE_CODE 1

char checkTag(char c1, char c2)
{
  if(c1=='<' && c2=='?') {
    return TAG_OPEN_CODE;
  }

  if(c1=='?' && c2=='>') {
    return TAG_CLOSE_CODE;
  }

  return TAG_NONE;
}

void printHTML(unsigned char *buf)
{
  if(buf[0])
  {
    int i=0;
    printf("cgiPrintf(cgi,\"%%s\", (char[]){");

    while(buf[i])
    {
      if(i>0) printf(",");
      printf("%d",buf[i]);
      ++i;
    }

    printf(",0});\n");
  }
}

void printCode(unsigned char *buf)
{
  if(buf[0]) printf("%s",buf);
}

void main(void)
{
  unsigned char bufType = BUF_TYPE_HTML;

  #define BUF_SZ 128
  unsigned char buf[BUF_SZ+1];

  int bufLen = 0;
  int lastChar = 0;

  memset(buf, 0, BUF_SZ+1);

  while(1)
  {
    lastChar = getchar();
    if(lastChar==EOF) break;
    if(bufLen>0) {
      char tagType = checkTag(buf[bufLen-1],lastChar);

      if(tagType==TAG_OPEN_CODE && bufType==BUF_TYPE_HTML)
      {
        buf[bufLen-1] = 0;
        printHTML(buf);
        bufType = BUF_TYPE_CODE;
        bufLen = 0;
      }
      else if(tagType==TAG_CLOSE_CODE && bufType==BUF_TYPE_CODE)
      {
        buf[bufLen-1] = 0;
        printCode(buf);
        bufType = BUF_TYPE_HTML;
        bufLen = 0;
      }
      else if(bufLen==BUF_SZ)
      {
        if(bufType==BUF_TYPE_CODE) {
          printCode(buf);
        } else {
          printHTML(buf);
        }
        bufLen = 0;
      } else {
        buf[bufLen] = lastChar;
        bufLen++;
        buf[bufLen] = 0;
      }

    } else {
      buf[0] = lastChar;
      bufLen = 1;
      buf[bufLen] = 0;
    }
  }

  if(bufLen)
  {
    buf[bufLen] = 0;
    if(bufType==BUF_TYPE_CODE) {
      printCode(buf);
    } else {
      printHTML(buf);
    }
  }

}
